# Author:	gong_libin
# Date:		2016_06_01

CC ?= g++
CFLAGS ?= -Wall -fPIC

GLB_ENV ?= $(shell pwd)/../..
GLB_LIB ?= $(GLB_ENV)/lib

GLB_GLIB ?= /usr/lib
GLB_GINC ?= /usr/include/GlbInc

OBJECTS = *.o

GLBGLOBAL = libglbglobal
GLBGLOBAL_A = $(GLBGLOBAL).a
GLBGLOBAL_SO = $(GLBGLOBAL).so
GLBGLOBAL_SO_VER = $(GLBGLOBAL_SO).1.1.0

TARGETS =				\
	$(GLBGLOBAL_A)			\
	$(GLBGLOBAL_SO_VER)

all: $(TARGETS) install

$(GLBGLOBAL_A): $(OBJECTS)
	ar cru $(GLBGLOBAL_A) $(OBJECTS)
	ranlib $(GLBGLOBAL_A)

$(GLBGLOBAL_SO_VER): $(OBJECTS)
	$(CC) $(CFLAGS) -shared -Wl,-soname,$(GLBGLOBAL_SO) -o $(GLBGLOBAL_SO_VER) $(OBJECTS)
	cp $(GLBGLOBAL).* $(GLB_LIB)/.

install:
	cp $(GLBGLOBAL).* $(GLB_GLIB)/.
	ln -s $(GLB_GLIB)/$(GLBGLOBAL_SO_VER) $(GLB_GLIB)/$(GLBGLOBAL_SO)

clean:
	rm -rf $(GLB_GLIB)/$(GLBGLOBAL).*
	rm -rf $(GLBGLOBAL_SO_VER)
	rm -rf $(GLBGLOBAL_A)
	rm -rf $(OBJECTS)
